package com.liangxy.news.database;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.liangxy.news.model.NewsDetail;

/**
 * Data Access Object for NewsDetail entity
 */
@Dao
public interface NewsDetailDao {
    
    /**
     * Insert news detail into the database
     * @param newsDetail NewsDetail to insert
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(NewsDetail newsDetail);
    
    /**
     * Update news detail in the database
     * @param newsDetail NewsDetail to update
     */
    @Update
    void update(NewsDetail newsDetail);
    
    /**
     * Delete news detail from the database
     * @param newsDetail NewsDetail to delete
     */
    @Delete
    void delete(NewsDetail newsDetail);
    
    /**
     * Get news detail by news ID
     * @param newsId News ID
     * @return NewsDetail with the given news ID
     */
    @Query("SELECT * FROM news_detail WHERE newsId = :newsId")
    NewsDetail getNewsDetailByNewsId(String newsId);
    
    /**
     * Update news detail timestamp
     * @param newsId News ID
     * @param timestamp New timestamp
     */
    @Query("UPDATE news_detail SET timestamp = :timestamp WHERE newsId = :newsId")
    void updateNewsDetailTimestamp(String newsId, long timestamp);
    
    /**
     * Delete all news details
     */
    @Query("DELETE FROM news_detail")
    void deleteAll();
} 